function scheduleHtmlParser(html) {
    let myDate = new Date();
    let month = myDate.getMonth() + 1;
    console.log(month);
    let courseInfos = [];
    for (let classNum = $('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().length - 1; classNum > 0; classNum--) {
        if ($('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().length == 8) {
            for (let week = $('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().length - 1; week > 0; week--) {
                if ($('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').length > 0) {
                    for (let z = $('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').length - 1; z >= 0; z--) {
                        let a = dataConversion($('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').eq(z).text(), classConversion(classNum, month), week);
                        courseInfos.push(a);
                    }
                }
            }
        } else {
            for (let week = $('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().length - 1; week > 0; week--) {
                if ($('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').length > 0) {
                    for (let z = $('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').length - 1; z >= 0; z--) {
                        let a = dataConversion($('#ctl00_ContentPlaceHolder1_CourseTable').children('tbody').children().eq(classNum).children().eq(week).children('table').eq(z).text(), classConversion(classNum, month), week - 1);
                        courseInfos.push(a);
                    }
                }
            }
        }
    }
    return {
        'courseInfos': courseInfos,
        'sectionTimes': sectionTimes(month),
    }
}
// 处理课程数据，老师，地址，第几周
function dataConversion(a, b, c) {
    let arr = a.trim().split(/\s+/);
    console.log(arr);
    let array = {};
    switch (arr.length) {
        case 3:
            array['name'] = arr[0].substring(0, arr[0].lastIndexOf("）") + 1);
            array['position'] = arr[1];
            array['teacher'] = arr[0].substring(arr[0].lastIndexOf("）") + 1, arr[0].length);
            array['weeks'] = weekConversion(arr[2]);
            array['day'] = c;
            array['sections'] = b;
            console.log(array);
            return array;
            break;
        case 4:
            array['name'] = arr[0].substring(0, arr[0].lastIndexOf("）") + 1);
            array['position'] = arr[2];
            array['teacher'] = arr[0].substring(arr[0].lastIndexOf("）") + 1, arr[0].length) + " " + arr[1];
            array['weeks'] = weekConversion(arr[3]);
            array['day'] = c;
            array['sections'] = b;
            console.log(array);
            return array;
            break;
        default:
            console.log("导入出现错误");
            break;
    }



    // let teacher = arr[0].substring(arr[0].lastIndexOf("）") + 1, arr[0].length);
    // let name = arr[0].substring(0, arr[0].lastIndexOf("）") + 1);
    // let position = arr[1];
    // let weeks = weekConversion(arr[2]);
    // let day=c;
    // let sections=b;
    // console.log(name, teacher, position, weeks,day,sections)

}
// 处理周数
function weekConversion(a) {
    let weeks = [];
    let week_math = a.match(/\d+/g);
    let week_start = parseInt(week_math[0]);
    let week_end = parseInt(week_math[1]);
    //判断单双周
    switch (a.match(/\（.+\）/g)[0]) {
        case "（单周）":
            for (let i = week_start; i < week_end + 1; i++) {
                if (i % 2 != 0) {
                    weeks.push(i);
                }
            };
            break;
        case "（双周）":
            for (let i = week_start; i < week_end + 1; i++) {
                if (i % 2 == 0) {
                    weeks.push(i);
                }
            };
            break;
        default:
            for (let i = week_start; i < week_end + 1; i++) {
                weeks.push(i);
            };
    };
    return weeks;
}

// 第几节课
function classConversion(i, month) {
    if (month >= 10 || month < 5) {
        switch (i) {
            case 1:
                return [{
                        "section": 1,
                        "startTime": "08:10",
                        "endTime": "08:55"
                    },
                    {
                        "section": 2,
                        "startTime": "09:00",
                        "endTime": "09:45"
                    }
                ];
                break;
            case 2:
                return [{
                        "section": 3,
                        "startTime": "10:05",
                        "endTime": "10:50"
                    },
                    {
                        "section": 4,
                        "startTime": "10:55",
                        "endTime": "11:40"
                    }
                ];
                break;
            case 3:
                return [{
                        "section": 5,
                        "startTime": "14:00",
                        "endTime": "14:45"
                    },
                    {
                        "section": 6,
                        "startTime": "14:50",
                        "endTime": "15:35"
                    }
                ];
                break;
            case 4:
                return [{
                        "section": 7,
                        "startTime": "15:55",
                        "endTime": "16:40"
                    },
                    {
                        "section": 8,
                        "startTime": "16:45",
                        "endTime": "17:30"
                    }
                ];
                break;
            default:
                return [{
                        "section": 9,
                        "startTime": "18:15",
                        "endTime": "19:00"
                    },
                    {
                        "section": 10,
                        "startTime": "19:05",
                        "endTime": "19:50"
                    },
                    {
                        "section": 11,
                        "startTime": "19:55",
                        "endTime": "20:40"
                    }
                ];
                break;
        }
    } else {
        switch (i) {
            case 1:
                return [{
                        "section": 1,
                        "startTime": "08:10",
                        "endTime": "08:55"
                    },
                    {
                        "section": 2,
                        "startTime": "09:00",
                        "endTime": "09:45"
                    }
                ];
                break;
            case 2:
                return [{
                        "section": 3,
                        "startTime": "10:05",
                        "endTime": "10:50"
                    },
                    {
                        "section": 4,
                        "startTime": "10:55",
                        "endTime": "11:40"
                    }
                ];
                break;
            case 3:
                return [{
                        "section": 5,
                        "startTime": "14:30",
                        "endTime": "15:15"
                    },
                    {
                        "section": 6,
                        "startTime": "15:20",
                        "endTime": "16:05"
                    }
                ];
                break;
            case 4:
                return [{
                        "section": 7,
                        "startTime": "16:25",
                        "endTime": "17:10"
                    },
                    {
                        "section": 8,
                        "startTime": "17:15",
                        "endTime": "18:00"
                    }
                ];
                break;
            default:
                return [{
                        "section": 9,
                        "startTime": "18:45",
                        "endTime": "19:30"
                    },
                    {
                        "section": 10,
                        "startTime": "19:35",
                        "endTime": "20:20"
                    },
                    {
                        "section": 11,
                        "startTime": "20:25",
                        "endTime": "21:10"
                    }
                ];
                break;
        }
    }

}

function sectionTimes(month) {
    if (month >= 10 || month < 5) {
        return [{
                "section": 1,
                "startTime": "08:10",
                "endTime": "08:55"
            },
            {
                "section": 2,
                "startTime": "09:00",
                "endTime": "09:45"
            },
            {
                "section": 3,
                "startTime": "10:05",
                "endTime": "10:50"
            },
            {
                "section": 4,
                "startTime": "10:55",
                "endTime": "11:40"
            },
            {
                "section": 5,
                "startTime": "14:00",
                "endTime": "14:45"
            },
            {
                "section": 6,
                "startTime": "14:50",
                "endTime": "15:35"
            },
            {
                "section": 7,
                "startTime": "15:55",
                "endTime": "16:40"
            },
            {
                "section": 8,
                "startTime": "16:45",
                "endTime": "17:30"
            },
            {
                "section": 9,
                "startTime": "18:15",
                "endTime": "19:00"
            },
            {
                "section": 10,
                "startTime": "19:05",
                "endTime": "19:50"
            },
            {
                "section": 11,
                "startTime": "19:55",
                "endTime": "20:40"
            }
        ];
    } else {
        return [{
                "section": 1,
                "startTime": "08:10",
                "endTime": "08:55"
            },
            {
                "section": 2,
                "startTime": "09:00",
                "endTime": "09:45"
            },
            {
                "section": 3,
                "startTime": "10:05",
                "endTime": "10:50"
            },
            {
                "section": 4,
                "startTime": "10:55",
                "endTime": "11:40"
            },
            {
                "section": 5,
                "startTime": "14:30",
                "endTime": "15:15"
            },
            {
                "section": 6,
                "startTime": "15:20",
                "endTime": "16:05"
            },
            {
                "section": 7,
                "startTime": "16:25",
                "endTime": "17:10"
            },
            {
                "section": 8,
                "startTime": "17:15",
                "endTime": "18:00"
            },
            {
                "section": 9,
                "startTime": "18:45",
                "endTime": "19:30"
            },
            {
                "section": 10,
                "startTime": "19:35",
                "endTime": "20:20"
            },
            {
                "section": 11,
                "startTime": "20:25",
                "endTime": "21:10"
            }
        ];
    }

}